package com.Sv;

import java.io.PrintWriter;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.*;

import org.apache.log4j.Logger;

import com.Sql.*;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import util.*;


public class testSv {
	
	
	
	private MSDao dao = null;
	private utill ut = null;
	
	private static Logger Log = Logger.getLogger(testSv.class);
	public static testSv instance = null;
	
	public static testSv getInstance(){
		if(instance == null){
			instance = new testSv();
		}
		return instance;
	}
	

public Map<String,Object> getMinfo(Map<String,Object> param){
	
	dao = new MSDao();

	
	Map<String,Object> result = new HashMap<String,Object>();
	List<Map<String,Object>> l = new ArrayList<Map<String,Object>>();
	try{
		
		result.put("List",dao.getList("access.getMinfo",param));
		
		
		
		l = (List<Map<String,Object>>)result.get("List");
    
	
		for(Map<String,Object> so : l){
		result.put("id",so.get("id"));	
		}
		
		
	
		
		
		if(ut.isnull(result.get("id")).equals(param.get("uid")))
			result.put("check",1);
		else
			result.put("check",0);
		
			
	}catch(Exception e){
		Log.error("e - error :"+e.getMessage());
	}
	return result;
}

public Map<String,Object> getZipcode(Map<String,Object> param){
	

	
		dao = new MSDao();
		
		Map<String,Object> result = new HashMap<String,Object>();
		List<Map<String,Object>> l = new ArrayList<Map<String,Object>>();
		try{
			
			result.put("List",dao.getList("access.getZipcode",param));
			
	
		}catch(Exception e){
			Log.error("e - error :"+e.getMessage());
			
		}
		return result;
	
	
	
}

public Map<String,Object> insertMember(Map<String,Object> param){
	

	
	dao = new MSDao();
	
	Map<String,Object> result = new HashMap<String,Object>();
	List<Map<String,Object>> l = new ArrayList<Map<String,Object>>();
	
	try{
		//주소//
		String zip1 = (String)param.get("zip1");
		String zip2 = (String)param.get("zip2");
		String addr1 = (String)param.get("addr1");
		String addr2 = (String)param.get("addr2");
		String addr = zip1+"-"+zip2+" "+addr1+" "+addr2;
		param.put("addr",addr);
		//집전화번호//
		String tel1 = (String)param.get("phone1");
		String tel2 = (String)param.get("phone2");
		String tel3 = (String)param.get("phone3");
		String htel = tel1+"-"+tel2+"-"+tel3;
		param.put("htel",htel);
		//휴대폰전화번호//
		String ptel1 = (String)param.get("mobile1");
		String ptel2 = (String)param.get("mobile2");
		String ptel3 = (String)param.get("mobile3");
		String ptel = ptel1+"-"+ptel2+"-"+ptel3;
		param.put("ptel",ptel);
		//이메일주소//
		String mail1 = (String)param.get("email1");
		String mail2 = (String)param.get("email2");
		String email = mail1+"@"+mail2;
		param.put("email",email);
		//생일// 
		String cal1 = (String)param.get("cal1");
		String cal2 = (String)param.get("cal2");
		String cal3 = (String)param.get("cal3");
		String cal_solar = (String)param.get("cal_solar");
		String birth = cal1+"년"+cal2+"월"+cal3+"일"+" "+cal_solar;
		param.put("birth",birth);
		
	
		
		System.out.println("param:"+param.toString());
		dao.getInsert("access.getInsert",param);
		
		

	}catch(Exception e){
		Log.error("e - error :"+e.getMessage());
		
	}
	return result;



}

public Map<String,Object> LoginCheck(Map<String,Object> param){
	
	dao = new MSDao();
	Map<String,Object> result = new HashMap<String,Object>();
	List<Map<String,Object>> l = new ArrayList<Map<String,Object>>();
	
	try{
	
		int c = dao.getInt("access.getCheck",param);
	
		System.out.println(c);
	//idcheck
		if(c==0){
			result.put("count","0");
		}else{
		result.put("list",dao.getList("access.getMinfo",param));
		result.put("count","1");
		l = (List<Map<String,Object>>)result.get("list");
		System.out.println("!!!!!!!!:"+l);
		for(Map<String,Object> vo : l){
			result.put("pwd",vo.get("pwd"));
			result.put("name",vo.get("name"));
		}
		
		}
			
	
		
	System.out.println(c);

	
	}catch(Exception e){
		
		Log.error("e - error :"+e.getMessage());
	}	
	
	return result;
	
	
}
	
	
	
	
	
}
